<template>
  <div>
    <el-dialog title="添加" width="600px" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
      <el-form :size="size" ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="单据编号" prop="bill_no">
              <el-input  v-model="form.bill_no" autoComplete="off" clearable  placeholder="请输入单据编号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产订单号" prop="task_bill_no">
              <el-input  v-model="form.task_bill_no" autoComplete="off" clearable  placeholder="请输入生产订单号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="状态" prop="status">
              <template>
                <el-radio v-model="form.status" label=0>未审核</el-radio>
                <el-radio v-model="form.status" label=1>已审核</el-radio>
              </template>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="重量" prop="count">
              <el-input  v-model="form.count" autoComplete="off" clearable  placeholder="请输入重量"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="仓库" prop="stock_no">
              <el-input  v-model="form.stock_no" autoComplete="off" clearable  placeholder="请输入仓库编号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="审核人" prop="audit_user_name">
              <el-input  v-model="form.audit_user_name" autoComplete="off" clearable  placeholder="请输入审核人"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="审核时间" prop="audit_user_name">
              <div class="block">
                <el-date-picker
                    v-model="form.audit_time"
                    type="datetime"
                    placeholder="选择日期时间">
                </el-date-picker>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" :loading="loading" type="primary" @click="submit" >
          <span v-if="!loading">确 定</span>
          <span v-else>提 交 中...</span>
        </el-button>
        <el-button :size="size" @click="closeForm">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { add  } from '@/api/admin/produce'

export default {
  name:'produceadd',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: false
    },
  },
  data(){
    return {
      form: {
        status:1,
        bill_no:'',
        task_bill_no:'',
        count:0,
        audit_user_name:'',
        stock_no:'',
        audit_time:null
      },
      loading:false,
      options:[],
      defaultProps: {
        children: "children",
        label: "title"
      },
      rules: {
      }
    }
  },
  watch: {

  },
  methods: {
    open(){
    },
    submit(){
      this.$refs['form'].validate(valid => {
        if(valid) {
          this.loading = true
      console.log(this.form)
          add(this.form).then(res => {
            if(res.status == 200){
              this.$message({message: '操作成功', type: 'success'})
              this.$emit('refresh_list')
              this.closeForm()
            }
          }).catch(()=>{
            this.loading = false
          })
        }
      })
    },

    closeForm(){
      this.$emit('update:show', false)
      this.loading = false
      if (this.$refs['form']!==undefined) {
        this.$refs['form'].resetFields()
      }
    },
  }
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss';
</style>
